home *** CD-ROM | disk | FTP | other *** search
- /* This script converts all selected snapshots to the format you want */
-
- /* test if emulator is present */
- address command
-
- if ~show(ports,ZXAM_REXX) then do
- requestchoice '>nil: title "ZXAM Script error..." body "I can''t find the emulator''s port!!" gadgets "AARGH!"'
- exit
- end
-
- /* old window status */
- oldname=zxamactname()
- oldformat=zxamactformat()
- oldsaveformat=zxamactsaveformat()
-
- /* ask for the files to be converted */
- 'requestfile >t:zxamconvert.tmp "'zxamactloadpath()'" title "Select snapshots to convert..." pattern 'zxamactpattern()' multiselect'
- names=zxampploadfile('t:zxamconvert.tmp')
- names=left(names,length(names)-1) /* discard LF */
-
- /* asf for destination drawer */
- 'requestfile >t:zxamconvert.tmp "'zxamactsavepath()'" drawersonly savemode'
- destdrawer=zxampploadfile('t:zxamconvert.tmp')
- destdrawer=strip(left(destdrawer,length(destdrawer)-1),'B','"') /* discard LF and " */
-
- /* ask for destination format */
- requestchoice '>t:zxamconvert.tmp "ZXAM convert..."' '"What format do you want?"' GADGETS "PC|PC_PP|MIRAGE|MIRAGE_PP|CANCEL"
- destformat=zxampploadfile('t:zxamconvert.tmp')
- destformat=left(destformat,length(destformat)-1) /* discard LF */
-
- if names='' then exit
-
- if destformat=0 then exit /* CANCEL */
-
- if destformat=1 then do
- destextension='.SP'
- destformname='pc'
- crunched=0
- end
-
- if destformat=2 then do
- destextension='.SP'
- destformname='pc'
- crunched=1
- end
-
- if destformat=3 then do
- destextension='.mirage'
- destformname='mirage'
- crunched=0
- end
-
- if destformat=4 then do
- destextension='.mirage'
- destformname='mirage'
- crunched=1
- end
-
- ZXAMSaveFormat(destformname) /* destination format */
-
- ZXAMEnableAbort() /* enables the 'Abort ARexx' gadget */
-
- /* inside the loop we extract and process the selected files */
- /* we change the extension of the file to the suitable for */
- /* the destination format */
-
- do forever
- name=strip(left(names,pos('"',names,2)),'B','"') /* extract the path&name */
- nameonly=zxamfilepart(name)
-
- if ZXAMReadAbort() then signal cleanup
-
- /* process the file */
-
- zxamnameformat('Loading "'nameonly'"','Wait...')
-
- block=zxampploadfile(name)
- origformat=zxamparseloaded(block)
-
- namenoext=nameonly
- if lastpos('.',namenoext)~=0 then namenoext=left(namenoext,lastpos('.',namenoext)-1)
- /* namenoext is the file name without extension */
-
- if origformat~='' then do
- block=zxamparsetosave()
- if crunched then
- do
- zxamnameformat('Compressing "'nameonly'"','Wait...')
- zxamppsavefile(zxamjoinpathname(destdrawer,namenoext)destextension,block)
- end
- else
- do
- zxamnameformat('Saving "'nameonly'"','Wait...')
- /* abrimos el fichero */
- if ~open('fichero',zxamjoinpathname(destdrawer,namenoext)destextension,'W') then signal cleanup
-
- /* write the snapshot to the file */
- dummy=writech('fichero',block)
-
- dummy=close('fichero')
- end
- end
-
- if pos('"',names,2)=length(names) then signal cleanup /* end of list */
- names=right(names,length(names)-(length(name)+3))
-
- end
-
-
- cleanup:
- if oldname='' then
- zxamclearnameformat()
- else
- zxamnameformat(oldname,oldformat)
-
- zxamsaveformat(oldsaveformat)
-
- exit
-